﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Tong;
/*一般创建 实例为 TextThisSite*/
namespace Tong.ThisSiteUse
{



    /// <summary>
    /// 一般创建 实例为 TextThisSite
    /// 这个系统所用到的系统方法 
    /// 包括文件生成类
    /// 返回后缀名 方法
    /// </summary>
    public class SiteTong
    {

        /// <summary>
        /// 数据操作方法
        /// </summary>
        TongUse TextData = new TongUse();



        #region  数据调用常用方法
        /// <summary>
        /// 传入要生成的 新闻ID 得到新闻生成的 ID 后缀扩展  
        /// </summary>
        /// <param name="id">传入要生成的 新闻ID </param>
        /// <returns></returns>
        public String SiteGetNewsFileLast(string id)
        {
            try
            {
                if (int.Parse(id).ToString() != "")
                {
                    string xx = TextData.SqlataSet("select CX_NEWS_Class_id from [CX_NEWS] where CX_NEWS_id =" + id).Tables[0].Rows[0][0].ToString(); //得到栏目ID
                    return TextData.SqlataSet("select CX_NEWS_Class_CreateFielfront from [CX_NEWS_Class] where CX_NEWS_Class_id =" + xx).Tables[0].Rows[0][0].ToString();
                }
                else
                {
                    return "";
                }
            }
            catch//(Exception ex)
            {
                return "";// +ex.Message;
            }

        }


        /// <summary>
        ///传入新闻分类ID 得到对应的栏目表 DataTable
        /// </summary>
        /// <param name="id">传入栏目 新闻分类ID</param>
        /// <returns>DataTable</returns>
        public DataTable SiteGetNewsGiveClassID_CloumnTable(string id)
        {
            DataTable GetNewsIDCloumnTable = new DataTable();//数据表
            try
            {
                if (int.Parse(id).ToString() != "")
                {
                    string xx = TextData.SqlataSet("select CX_Column_id from [CX_NEWS_Class] where  CX_NEWS_Class_id=" + id).Tables[0].Rows[0][0].ToString(); //得到栏目ID
                    return TextData.SqlataSet("select * from [CX_Column] where CX_Column_id =" + xx).Tables[0];//得到栏目表
                }
                else
                {
                    return GetNewsIDCloumnTable;
                }
            }
            catch//(Exception ex)
            {
                return GetNewsIDCloumnTable;// +ex.Message;
            }
        }

        /// <summary>
        /// 传入新闻分类ID 得到新闻 的 生成目录 
        /// </summary>
        /// <param name="id">传入新闻分类ID</param>
        /// <returns></returns>
        public string SiteGetNewsDirLink(string id)
        {
            try
            {
                if (int.Parse(id).ToString() != "")
                {
                    return TextData.SqlataSet("select CX_NEWS_Class_Directory from [CX_NEWS_Class] where CX_NEWS_Class_id =" + id).Tables[0].Rows[0]["CX_NEWS_Class_Directory"].ToString(); //新闻 的 生成目录 
                }
                else
                {
                    return "";
                }
            }
            catch
            {
                return "";
            }
        }


        /// <summary>
        ///传入要生成的 新闻ID 得到新闻生成的 目录
        /// </summary>
        /// <param name="id">传入要生成的 新闻ID </param>
        /// <returns></returns>
        public String SiteGetNewsSetCrtDir(string id)
        {
            try
            {
                if (int.Parse(id).ToString() != "")
                {
                    string xx = TextData.SqlataSet("select CX_NEWS_Class_id from [CX_NEWS] where CX_NEWS_id =" + id).Tables[0].Rows[0][0].ToString(); //得到新闻分类ID
                    return TextData.SqlataSet("select CX_NEWS_Class_Directory from [CX_NEWS_Class] where CX_NEWS_Class_id =" + xx).Tables[0].Rows[0][0].ToString();
                }
                else
                {
                    return "";
                }
            }
            catch//(Exception ex)
            {
                return "";// +ex.Message;
            }

        }


        /// <summary>
        /// 传入新闻分类ID 得到新闻 的 数据的 模板 文件及参数
        /// </summary>
        /// <param name="id">传入新闻分类ID</param>
        /// <returns></returns>
        public string SiteGetNewsDirPage(string id)
        {
            try
            {
                if (int.Parse(id).ToString() != "")
                {
                    DataTable NewDirPage = new DataTable();
                    NewDirPage = TextData.SqlataSet("select CX_NEWS_Class_Itemplitate_Address,CX_NEWS_Class_Itemplitate_Parame from [CX_NEWS_Class] where CX_NEWS_Class_id =" + id).Tables[0];
                    return NewDirPage.Rows[0]["CX_NEWS_Class_Itemplitate_Address"].ToString() + NewDirPage.Rows[0]["CX_NEWS_Class_Itemplitate_Parame"].ToString();
                    NewDirPage.Dispose();
                }
                else
                {
                    return "";
                }
            }
            catch
            {
                return "";
            }
        }


        /// <summary>
        /// 传入栏目 ID 得到 一 条 新闻分类  ID
        /// </summary>
        /// <param name="id">传入栏目 ID</param>
        /// <returns></returns>
        public String SiteGetNewsClassIDGiveCloumnID(string id)
        {
            try
            {
                if (int.Parse(id).ToString() != "")
                {
                    string xx = TextData.SqlataSet("select CX_Column_id from [CX_Column] where CX_Column_id =" + id).Tables[0].Rows[0][0].ToString(); //得到栏目ID
                    return TextData.SqlataSet("select CX_NEWS_Class_id from [CX_NEWS_Class] where CX_Column_id =" + xx).Tables[0].Rows[0][0].ToString();
                }
                else
                {
                    return "";
                }
            }
            catch//(Exception ex)
            {
                return "";// +ex.Message;
            }
        }

        /// <summary>
        /// 传入 栏目ID 得到 栏目生成 目录
        /// </summary>
        /// <param name="id">传入 栏目ID</param>
        /// <returns></returns>
        public String SiteGetColumnDirLink(string id)
        {
            try
            {
                if (int.Parse(id).ToString() != "")
                {
                    return TextData.SqlataSet("select CX_Column_Directory from [CX_Column] where CX_Column_id =" + id).Tables[0].Rows[0][0].ToString();
                }
                else
                {
                    return "";
                }
            }
            catch
            {
                return "";
            }
        }

        /// <summary>
        /// 传入 栏目ID 得到 栏目 数据的 Get 文件 及参数
        /// </summary>
        /// <param name="id">传入 栏目ID</param>
        /// <returns></returns>
        public String SiteGetColumnDirPage(string id)
        {
            try
            {
                if (int.Parse(id).ToString() != "")
                {
                    DataTable ColumnDirPage = new DataTable();
                    ColumnDirPage = TextData.SqlataSet("select CX_Column_ItemTemplate_Url,CX_Column_ItemTeplate_Parame from [CX_Column] where CX_Column_id =" + id).Tables[0];
                    return ColumnDirPage.Rows[0]["CX_Column_ItemTemplate_Url"].ToString() + ColumnDirPage.Rows[0]["CX_Column_ItemTeplate_Parame"].ToString();
                    ColumnDirPage.Dispose();
                }
                else
                {
                    return "";
                }
            }
            catch
            {
                return "";
            }
        }


        /// <summary>
        /// 传入 栏目ID 得到 对应该 栏目 表名
        /// </summary>
        /// <param name="id">传入 栏目ID</param>
        /// <returns></returns>
        public String SigeGetColumnTable(string id)
        {
            try
            {
                if (int.Parse(id).ToString() != "")
                {
                    return TextData.SqlataSet("select CX_CX_Column_Tab_Name from [CX_Column] where CX_Column_id =" + id).Tables[0].Rows[0][0].ToString();
                }
                else
                {
                    return "";
                }
            }
            catch
            {
                return "";
            }

        }

        /// <summary>
        /// 传入 栏目 表  得到 对应该 栏目 ID
        /// </summary>
        /// <param name="TableX">传入 栏目 表名</param>
        /// <returns></returns>
        public String SiteGetColumnID(string TableX)
        {
            try
            {
                if (TableX != "")
                {
                    return TextData.SqlataSet("select CX_Column_id from [CX_Column] where  CX_CX_Column_Tab_Name='" + TableX + "'").Tables[0].Rows[0][0].ToString();
                }
                else
                {
                    return "";
                }
            }
            catch
            {
                return "";
            }
        }



        /// <summary>
        /// 传入ＳＱＬ语句，获取一个字段的值 张立海10月30号加入
        /// </summary>
        /// <param name="id">传入 SQL语名</param>
        /// <returns></returns>
        public String SqlOne(string SqlTxt, string Field)
        {
            try
            {
                if (SqlTxt != "" && Field != "")
                {
                    return TextData.SqlataSet(SqlTxt).Tables[0].Rows[0][Field].ToString();
                }
                else
                {
                    return "";
                }
            }
            catch
            {
                return "";
            }

        }

        /// <summary>
        /// 当前栏目ID
        /// </summary>
        int SiteGetColumnLvTempCloumnID = 0;

        /// <summary>
        /// 临时用于得到级别的变量
        /// </summary>
        int SiteGetColumnLvss = 0;
        /// <summary>
        /// 栏目ID的级别
        /// </summary>
        int SiteGetColumnLvii = 0;

        /// <summary>
        /// 传入栏目ID 得到栏目级别
        /// </summary>
        /// <param name="select">传入 0 </param>
        /// <param name="PointCloumnID">要指定显示的ID</param>
        /// <![CDATA[
        /// 用法 (SiteGetColumnLv(0, 328)
        /// ]]>
        /// <returns></returns>
        public int SiteGetColumnLv(int select, int PointCloumnID)
        {
            string sql;
            int i = 0;
            if (SiteGetColumnLvTempCloumnID != PointCloumnID)
            {
                SiteGetColumnLvTempCloumnID = PointCloumnID;
                SiteGetColumnLvss = 0;
                SiteGetColumnLvii = 0;
            }
            DataTable SiteGetColumnLvMyDt = new DataTable();
            sql = "Select * From CX_Column where CX_Column_LX<>3 and CX_Column_followid =" + select + " order by CX_Column_id desc";
            try
            {
                SiteGetColumnLvMyDt = TextData.SqlataSet(sql).Tables[0];//创建DataTable MyDt
            }
            catch (Exception ex)
            {
                TextData.Err(ex.Message);

            }
            for (i = 0; i < SiteGetColumnLvMyDt.Rows.Count; i++)//遁环记录集
            {
                if (PointCloumnID == int.Parse(SiteGetColumnLvMyDt.Rows[i]["CX_Column_id"].ToString()))//如果是当前层，则显示自己的级别
                {
                    SiteGetColumnLvss = SiteGetColumnLvii;
                    break;
                }
                else
                {
                    SiteGetColumnLvii = SiteGetColumnLvii + 1;
                    SiteGetColumnLv(int.Parse(SiteGetColumnLvMyDt.Rows[i]["CX_Column_id"].ToString()), PointCloumnID);//调用自己显示自己的级别
                    SiteGetColumnLvii -= 1;
                }
            }
            return SiteGetColumnLvss;


        }


        /// <summary>
        /// 循环栏目的级别
        /// </summary>
        int GetColumnPointii = 0;

        /// <summary>
        /// 指定的栏目
        /// </summary>
        string GetColumnPointFarCloumnID = "";

        /// <summary>
        /// 输出HTML
        /// </summary>
        string GetColumnPointoutHTML = "";


        /// <summary>
        /// 得到指定栏目下的指定级别的所有栏目 
        /// 目前只支持 下面一个子栏目
        /// 通用用于关键字的列表
        /// </summary>
        /// <param name="FarCloumnID">指定的栏目</param>
        /// <param name="ShowCloumnLv">指定显示指定栏目下的显示最多的级别  "-1"  为只选出指定大类的栏目名</param>
        /// <returns></returns>
        public String GetColumnPoint(string FarCloumnID, string ShowCloumnLv)
        {
            string GetColumnPointsql = "";
            DataTable GetColumnPoint_DataTable = new DataTable();
            string TempText = "";

            //看看是不是有指定栏目 如果是下一个的话就清空
            if (GetColumnPointFarCloumnID != FarCloumnID)
            {
                GetColumnPointFarCloumnID = "";
            }
            if (GetColumnPointFarCloumnID != "")
            {
                GetColumnPointsql = "select * from [CX_Column] where CX_Column_followid=" + FarCloumnID + " order by CX_Column_Sort desc,CX_Column_id desc ";//得到栏目下的栏目

                GetColumnPoint_DataTable = TextData.SqlataSet(GetColumnPointsql).Tables[0];//创建 DataTable 

                //子循环
                for (int GetColumnPointi = 0; GetColumnPointi < GetColumnPoint_DataTable.Rows.Count; GetColumnPointi++)
                {
                    if (int.Parse(ShowCloumnLv) == GetColumnPointii)//当前栏目级别
                    {

                        GetColumnPointoutHTML += "\t\t<li><a href=\"" + GetColumnPoint_DataTable.Rows[GetColumnPointi]["CX_Column_Directory"].ToString() + "1.html\">" + GetColumnPoint_DataTable.Rows[GetColumnPointi]["CX_Column_Name"].ToString() + " </a></li>\r\n";
                    }
                    GetColumnPointii = GetColumnPointii + 1;
                    //如果在指定的级别
                    if (int.Parse(ShowCloumnLv) >= GetColumnPointii)
                    {
                        // TextData.Res.Response.Write(FarCloumnID + "<br/>");
                        GetColumnPoint(GetColumnPoint_DataTable.Rows[0]["CX_Column_id"].ToString(), ShowCloumnLv);//调用自己显示THML

                    }
                    GetColumnPointii -= 1;
                }
            }
            else
            {
                GetColumnPointFarCloumnID = FarCloumnID;//传入ID
                GetColumnPointsql = "select * from [CX_Column]   where CX_Column_id=" + GetColumnPointFarCloumnID + " order by CX_Column_Sort desc,CX_Column_id desc ";//首次进行

                GetColumnPoint_DataTable = TextData.SqlataSet(GetColumnPointsql).Tables[0];//创建 DataTable 

                //得到指定栏目名称
                GetColumnPointoutHTML = "\r\n<h1><a href=\"" + GetColumnPoint_DataTable.Rows[0]["CX_Column_Directory"].ToString() + "1.html\">" + GetColumnPoint_DataTable.Rows[0]["CX_Column_Name"].ToString() + " </a></h1>\r\n\t<ul>\r\n";

                if (ShowCloumnLv == "-1")//只选出大类的栏目名
                {
                    return "\r\n<h1><a href=\"" + GetColumnPoint_DataTable.Rows[0]["CX_Column_Directory"].ToString() + "1.html\">" + GetColumnPoint_DataTable.Rows[0]["CX_Column_Name"].ToString() + " </a></h1>\r\n\t";
                }
                else
                {
                    GetColumnPoint(GetColumnPoint_DataTable.Rows[0]["CX_Column_id"].ToString(), ShowCloumnLv);//开始子物循环

                }

            }

            //如果没有的话
            if (GetColumnPointoutHTML.IndexOf("</ul>") == -1)
            {
                TempText = GetColumnPointoutHTML;
                TempText += "\t</ul>";
            }

            return TempText;
        }




        /// <summary>
        /// 循环栏目的级别
        /// </summary>
        int GetColumnsPointHtmlTagii = 0;

        /// <summary>
        /// 多少次循环一个 HTML标签
        /// </summary>
        int GetColumnsPointHtmlTagHTMLTagsNum = 0;

        /// <summary>
        /// 指定的栏目
        /// </summary>
        string GetColumnsPointHtmlTagFarCloumnID = "";

        /// <summary>
        /// 输出HTML
        /// </summary>
        string GetColumnsPointHtmlTagoutHTML = "";


        /// <summary>
        /// 得到指定栏目下的指定级别的所有栏目 
        /// 控制参数 只支持下面一个子栏目 如果有多个将重复
        /// 要换行或控制显示时使用
        /// </summary>
        /// <param name="FarCloumnID">指定的栏目</param>
        /// <param name="ShowCloumnLv">指定显示指定栏目下的显示最多的级别</param>
        /// <param name="HTMLTag">相当于tr的HTML标签 不指定为空</param>
        /// <param name="HTMLTagsNum">循环出一个指定html标签 所要的循环次数 </param>
        /// <param name="oldHtmlTag">循环的基本标签</param>
        /// <param name="LinkColumnDirName">输出HTML标签的LINK地址目录 </param>
        /// <returns> </returns>
        /// <![CDATA[
        ///用法 GetColumnsPointHtmlTag(Eval("CX_Column_id").ToString(), "0", "<ul>", 2,"<li>") 
        ///
        ///]]>
        public String GetColumnsPointHtmlTag(string FarCloumnID, string ShowCloumnLv, string HTMLTag, int HTMLTagsNum, string oldHtmlTag)
        {
            string GetColumnsPointHtmlTagsql = "";
            DataTable GetColumnsPointHtmlTag_DataTable = new DataTable();
            string TempText = "";
            //看看是不是有指定栏目 如果是下一个的话就清空
            if (GetColumnsPointHtmlTagFarCloumnID != FarCloumnID)
            {
                GetColumnsPointHtmlTagFarCloumnID = "";

            }
            if (GetColumnsPointHtmlTagFarCloumnID != "")
            {
                GetColumnsPointHtmlTagsql = "select * from [CX_Column] where CX_Column_followid=" + FarCloumnID + " order by CX_Column_Sort desc,CX_Column_id desc ";//得到栏目下的栏目

                GetColumnsPointHtmlTag_DataTable = TextData.SqlataSet(GetColumnsPointHtmlTagsql).Tables[0];//创建 DataTable 
                //子循环
                for (int GetColumnsPointHtmlTagi = 0; GetColumnsPointHtmlTagi < GetColumnsPointHtmlTag_DataTable.Rows.Count; GetColumnsPointHtmlTagi++)
                {
                    if (int.Parse(ShowCloumnLv) == GetColumnsPointHtmlTagii)//当前指定的栏目 如果要一层层显示请去掉 if
                    {
                        if (GetColumnsPointHtmlTagHTMLTagsNum == HTMLTagsNum)
                        {
                            GetColumnsPointHtmlTagoutHTML += "\t\t" + oldHtmlTag + "<a href=\"" + GetColumnsPointHtmlTag_DataTable.Rows[GetColumnsPointHtmlTagi]["CX_Column_Directory"].ToString() + "1.html\">" + GetColumnsPointHtmlTag_DataTable.Rows[GetColumnsPointHtmlTagi]["CX_Column_Name"].ToString() + " </a>" + oldHtmlTag.Replace("<", "</") + "\r\n" + HTMLTag.Replace("<", "</") + "\r\n";
                            GetColumnsPointHtmlTagHTMLTagsNum = 0;

                        }
                        else
                        {
                            if (GetColumnsPointHtmlTagHTMLTagsNum == 0)
                            {
                                GetColumnsPointHtmlTagoutHTML += HTMLTag + "\r\n";
                                GetColumnsPointHtmlTagoutHTML += "\t\t" + oldHtmlTag + "<a href=\"" + GetColumnsPointHtmlTag_DataTable.Rows[GetColumnsPointHtmlTagi]["CX_Column_Directory"].ToString() + "1.html\">" + GetColumnsPointHtmlTag_DataTable.Rows[GetColumnsPointHtmlTagi]["CX_Column_Name"].ToString() + " </a>" + oldHtmlTag.Replace("<", "</") + "\r\n";
                                GetColumnsPointHtmlTagHTMLTagsNum++;//标签加1
                            }
                            else
                            {
                                GetColumnsPointHtmlTagoutHTML += "\t\t" + oldHtmlTag + "<a href=\"" + GetColumnsPointHtmlTag_DataTable.Rows[GetColumnsPointHtmlTagi]["CX_Column_Directory"].ToString() + "1.html\">" + GetColumnsPointHtmlTag_DataTable.Rows[GetColumnsPointHtmlTagi]["CX_Column_Name"].ToString() + " </a>" + oldHtmlTag.Replace("<", "</") + "\r\n";
                                GetColumnsPointHtmlTagHTMLTagsNum++;//标签加1
                            }
                        }
                    }

                    GetColumnsPointHtmlTagii = GetColumnsPointHtmlTagii + 1;
                    //如果在指定的级别
                    if (int.Parse(ShowCloumnLv) >= GetColumnsPointHtmlTagii)
                    {
                        GetColumnsPointHtmlTag(GetColumnsPointHtmlTag_DataTable.Rows[0]["CX_Column_id"].ToString(), ShowCloumnLv, HTMLTag, HTMLTagsNum, oldHtmlTag);//调用自己显示THML
                    }
                    GetColumnsPointHtmlTagii -= 1;
                }
            }
            else
            {
                GetColumnsPointHtmlTagFarCloumnID = FarCloumnID;//传入ID
                GetColumnsPointHtmlTagsql = "select * from [CX_Column]   where CX_Column_id=" + GetColumnsPointHtmlTagFarCloumnID + " order by CX_Column_Sort desc,CX_Column_id desc ";//首次进行
                GetColumnsPointHtmlTag_DataTable = TextData.SqlataSet(GetColumnsPointHtmlTagsql).Tables[0];//创建 DataTable 
                //得到指定栏目名称
                GetColumnsPointHtmlTagoutHTML = "";
                GetColumnsPointHtmlTagHTMLTagsNum = 0;
                GetColumnsPointHtmlTag(GetColumnsPointHtmlTag_DataTable.Rows[0]["CX_Column_id"].ToString(), ShowCloumnLv, HTMLTag, HTMLTagsNum, oldHtmlTag);//调用自己显示THML

            }
            if (((GetColumnsPointHtmlTagoutHTML.Length - HTMLTag.Replace("<", "</").Length) - 2) > 0)
            {
                if (GetColumnsPointHtmlTagoutHTML.Substring((GetColumnsPointHtmlTagoutHTML.Length - HTMLTag.Replace("<", "</").Length) - 2, HTMLTag.Replace("<", "</").Length) == HTMLTag.Replace("<", "</"))
                {
                    TempText = GetColumnsPointHtmlTagoutHTML;
                }
                else
                {
                    TempText = GetColumnsPointHtmlTagoutHTML + HTMLTag.Replace("<", "</");

                }
            }


            return TempText;
        }


        /// <summary>
        /// 得到这个栏目下所有的新闻 返回DaTaTable返回栏目下所有的新闻
        /// 如果要调用 指定新闻栏目的新闻请不要使用此方法
        /// </summary>
        /// <param name="FarstColumn">这个栏目</param>
        /// <param name="tiaoshu">要调用的条数</param>
        ///  <param name="NewsLx">调用新闻类型  0为一般新闻,1 为头条新闻,2为图片新闻</param>
        /// <returns></returns>
        /// <![CDATA[
        ///思路,先得到所有的 要查找的这个栏目下的新闻栏目的ID 
        /// 再用SQL or 得到所有新闻
        ///
        /// ]]>
        public DataTable GetCloumnsAllNews(string FarstColumn, int tiaoshu, string NewsLx)
        {
            string sumx = "";//得到所有要搜索的栏目ID
            string[] tempstring;
            string NewsClassIDs = "";//所有的新闻分类ID

            DataTable NewsDataTable = new DataTable();
            //得到所有新闻的DataTable
            ///得到要查询栏目的ID
            Showbock(int.Parse(FarstColumn), "all");
            tempstring = Xtext1.Split('á');

            foreach (string Xstringx in tempstring)
            {
                if (Xstringx.Split('ā')[0] != "")
                {
                    sumx += "" + Xstringx.Split('ā')[0] + ",";//得到ID
                }

            }
            if (sumx != "")
            {
                sumx = sumx.Replace(" ", "");
                foreach (string NewsClassID in sumx.Split(','))
                {
                    if (NewsClassID != "")
                    {
                        DataTable GetCloumnsAllNewsNewsClassIDsTable = new DataTable();
                        GetCloumnsAllNewsNewsClassIDsTable = TextData.SqlataSet("select CX_NEWS_Class_id from [CX_NEWS_Class] where CX_Column_id=" + NewsClassID).Tables[0];
                        for (int GetCloumnsAllNewsi = 0; GetCloumnsAllNewsi < GetCloumnsAllNewsNewsClassIDsTable.Rows.Count; GetCloumnsAllNewsi++)
                        {
                            NewsClassIDs += "CX_NEWS_Class_id=" + TextData.SqlataSet("select CX_NEWS_Class_id from [CX_NEWS_Class] where CX_NEWS_Class_id=" + GetCloumnsAllNewsNewsClassIDsTable.Rows[GetCloumnsAllNewsi]["CX_NEWS_Class_id"].ToString()).Tables[0].Rows[0]["CX_NEWS_Class_id"].ToString() + " or ";
                        }
                    }
                }
            }


            if (NewsClassIDs != "")
            {
                string NewsTypeSql = "";
                if (NewsLx == "1")
                {
                    NewsTypeSql = " and CX_NEWS_Top='1' ";

                }

                if (NewsLx == "2")
                {
                    NewsTypeSql = " and CX_NEWS_Pic='1' ";
                }
                NewsClassIDs = NewsClassIDs.Substring(0, NewsClassIDs.Length - 3);
                //得到这个东东的所有新闻

                NewsDataTable = TextData.SqlataSet("select top " + tiaoshu + " * from [CX_NEWS] where (" + NewsClassIDs + ")" + NewsTypeSql + "  order by CX_NEWS_Sort desc,[CX_NEWS_PublicTime] desc, CX_NEWS_id desc").Tables[0];
                //TextData.Res.Response.Write(NewsTypeSql);
            }
            return NewsDataTable;
        }


        /// <summary>
        /// 传入栏目ID 返回这个栏目ID 对应的新闻
        /// </summary>
        /// <param name="CloumnDID">传入栏目ID</param>
        /// <param name="tiaoshu">要调用的条数</param>
        /// <param name="NewsLx">调用新闻类型  0为一般新闻,1 为头条新闻,2为图片新闻</param> 
        /// <returns></returns>
        public DataTable GetPointCloumnNews(string CloumnDID, int tiaoshu, string NewsLx)
        {
            DataTable GetPointCloumnNewsDataTable = new DataTable();
            if (SiteGetNewsClassIDGiveCloumnID(CloumnDID) != "")
            {
                string NewsTypeSql = "";
                if (NewsLx == "1")
                {
                    NewsTypeSql = " and CX_NEWS_Top='1' ";

                }

                if (NewsLx == "2")
                {
                    NewsTypeSql = " and CX_NEWS_Pic='1' ";
                }

                GetPointCloumnNewsDataTable = TextData.SqlataSet("select top " + tiaoshu + " * from [CX_NEWS] where CX_NEWS_Class_id=" + SiteGetNewsClassIDGiveCloumnID(CloumnDID) + NewsTypeSql + " order by CX_NEWS_Sort desc,[CX_NEWS_PublicTime] desc, CX_NEWS_id desc").Tables[0];
            }
            return GetPointCloumnNewsDataTable;
        }

        string Xtext = "";

        /// <summary>
        /// 在调用 Showbock(栏目ID,"栏目类型")后用此方法得到数据
        /// </summary>
        public string Xtext1
        {
            get
            {

                string sss = Xtext;
                Xtext = "";
                return sss;

            }
        }

        /// <summary>
        /// 得到这个栏目下所有的子栏目 格式为 idā名á 第二个
        /// </summary>
        /// <param name="CloumnID">栏目ID</param>
        /// <param name="CloumnLX">栏目类型 所有栏目请用 "all" 0为一般栏目,1为新闻</param>
        public void Showbock(int CloumnID, string CloumnLX)
        {
            string Showbockisql;
            Showbockisql = "select * from [CX_Column] where CX_Column_followid=" + CloumnID + " order by CX_Column_Sort desc,CX_Column_id desc";
            /// <summary>
            /// 用于保存栏目的临时表
            /// </summary>
            DataTable ShowbokckTablue = new DataTable();
            ShowbokckTablue = TextData.SqlataSet(Showbockisql).Tables[0];
            for (int Showbocki = 0; Showbocki < ShowbokckTablue.Rows.Count; Showbocki++)
            {

                Xtext += ShowbokckTablue.Rows[Showbocki]["CX_Column_id"].ToString() + "ā" + ShowbokckTablue.Rows[Showbocki]["CX_Column_Name"].ToString() + "á";
                //Xtext += ShowbokckTablue.Rows[Showbocki]["CX_Column_id"].ToString() + ShowbokckTablue.Rows[Showbocki]["CX_Column_Name"].ToString() + ",";
                Showbock(int.Parse(ShowbokckTablue.Rows[Showbocki]["CX_Column_id"].ToString()), CloumnLX);

            }



        }





        /// <summary>
        /// 看看是不是有新的栏目 ID
        /// </summary>
        string GetPointColumnsFarCloumnID = "";

        /// <summary>
        /// 得到的栏目 ID 集合
        /// </summary>
        string GetPointColumnsoutCloumnsID = "";

        /// <summary>
        /// 当前循环栏目的级别
        /// </summary>
        int GetPointColumnsii = 0;

        /// <summary>
        /// 得到指定栏目下 指定级别的栏目 返回 栏目表的 DataTable 
        /// </summary>
        /// <param name="CloumnID">指定栏目ID</param>
        /// <param name="CloumnLV">指定栏目级别 请从0级开始指定</param>
        /// <returns></returns>
        public DataTable GetPointColumns(string FarCloumnID, int CloumnLV)
        {

            string GetPointColumnssql = "";
            DataTable GetPointColumns_DataTable = new DataTable();
            DataTable GetPointColumnsReturnTable = new DataTable();//返回数据的DataTable;

            string TempText = "";

            //看看是不是有指定栏目 如果是下一个的话就清空
            if (GetPointColumnsFarCloumnID != FarCloumnID)
            {
                GetPointColumnsFarCloumnID = "";
            }
            if (GetPointColumnsFarCloumnID != "")
            {
                GetPointColumnssql = "select * from [CX_Column] where CX_Column_followid=" + FarCloumnID + " order by CX_Column_Sort desc,CX_Column_id desc ";//得到栏目下的栏目
                GetPointColumns_DataTable = TextData.SqlataSet(GetPointColumnssql).Tables[0];//创建 DataTable 

                //子循环
                for (int GetPointColumnsi = 0; GetPointColumnsi < GetPointColumns_DataTable.Rows.Count; GetPointColumnsi++)
                {
                    if (CloumnLV == (GetPointColumnsii))//当前指定的栏目 如果要一层层显示请去掉 if
                    {
                        GetPointColumnsoutCloumnsID += "  CX_Column_id=" + GetPointColumns_DataTable.Rows[GetPointColumnsi]["CX_Column_id"].ToString() + " or ";//得到栏目的 SQL 条件
                    }
                    GetPointColumnsii = GetPointColumnsii + 1;
                    //如果在指定的级别
                    if (CloumnLV >= GetPointColumnsii)
                    {
                        GetPointColumns(GetPointColumns_DataTable.Rows[0]["CX_Column_id"].ToString(), CloumnLV);//调用自己显示THML
                    }
                    GetPointColumnsii -= 1;

                }
            }
            else
            {
                GetPointColumnsFarCloumnID = FarCloumnID;//传入ID
                GetPointColumnssql = "select * from [CX_Column]   where CX_Column_id=" + GetPointColumnsFarCloumnID + " order by CX_Column_Sort desc,CX_Column_id desc ";//首次进行

                GetPointColumns_DataTable = TextData.SqlataSet(GetPointColumnssql).Tables[0];//创建 DataTable 

                //删除自己
                GetPointColumnsoutCloumnsID = "";

                GetPointColumns(GetPointColumns_DataTable.Rows[0]["CX_Column_id"].ToString(), CloumnLV);//开始子物循环
            }
            //如果有栏目的话
            if (GetPointColumnsoutCloumnsID.IndexOf(" or ") != -1)
            {
                TempText = GetPointColumnsoutCloumnsID.Substring(0, GetPointColumnsoutCloumnsID.Length - 3);//cut掉最后的 or 
                GetPointColumnsReturnTable = TextData.SqlataSet("select * from [CX_Column]   where " + TempText + " order by CX_Column_Sort desc ").Tables[0];
            }

            return GetPointColumnsReturnTable;
        }



        /// <summary>
        /// 当前循环栏目的级别
        /// </summary>
        int GetTopCloumnsii = 0;

        /// <summary>
        /// 指定栏目的返回dataTable
        /// </summary>
        DataTable GetTopCloumnsReturnTable = new DataTable();//返回数据的DataTable;

        /// <summary>
        /// 得到指定栏目 的指定 级别的 父栏目
        ///  </summary>
        /// <param name="PointCloumnID">指定栏目ID</param>
        /// <param name="ShowCloumnLv">指定 父栏目 相对于此栏目的逆向级别  以 0 开始</param>
        /// <returns></returns>
        public DataTable GetTopCloumns(string PointCloumnID, int ShowCloumnLv)
        {

            string GetTopCloumnssql = "";
            DataTable GetTopCloumns_DataTable = new DataTable();

            GetTopCloumnssql = "select * from [CX_Column] where CX_Column_id=" + PointCloumnID + " order by CX_Column_Sort desc,CX_Column_id desc ";//得到栏目下的栏目
            GetTopCloumns_DataTable = TextData.SqlataSet(GetTopCloumnssql).Tables[0];//创建 DataTable 

            //子循环
            for (int GetTopCloumnsi = 0; GetTopCloumnsi < GetTopCloumns_DataTable.Rows.Count; GetTopCloumnsi++)
            {

                GetTopCloumnsii = GetTopCloumnsii + 1;
                if (ShowCloumnLv >= GetTopCloumnsii && GetTopCloumns_DataTable.Rows[GetTopCloumnsi]["CX_Column_followid"].ToString() != "0")
                {
                    //栏目ID 
                    GetTopCloumnssql = "";
                    GetTopCloumnssql = " select * from [CX_Column] where   CX_Column_id=" + GetTopCloumns_DataTable.Rows[GetTopCloumnsi]["CX_Column_followid"].ToString() + " order by CX_Column_Sort desc,CX_Column_id desc";
                    GetTopCloumnsReturnTable = TextData.SqlataSet(GetTopCloumnssql).Tables[0];//得到当前表
                    GetTopCloumns(GetTopCloumns_DataTable.Rows[GetTopCloumnsi]["CX_Column_followid"].ToString(), ShowCloumnLv);//调用自己显示THML
                }

                GetTopCloumnsii -= 1;
            }
            return GetTopCloumnsReturnTable;
        }




        //制作导行类
        /// <summary>
        ///  导行方法  支择新闻,栏目,新闻分类
        /// 传入得到的ID  入得当前类型 是新闻表的新闻 还是栏目表下面的直接表
        /// </summary>
        /// <param name="CurrID">传入当前得到的ID</param>
        /// <param name="LX">新闻News#13;新闻类型Newslx&#13;栏目直属表Column&#13; </param>
        /// <returns></returns>
        public string SiteGetWebSiteMap(string CurrID, string LX)
        {
            //临时数据表
            DataTable WebSiteTable = new DataTable();
            //数据临时表
            DataTable WEBSiteTable = new DataTable();

            //web导行的字符串 
            string websitetext = "";

            ///新闻ID;
            string NewsIDWebSite = "";
            ///新闻分类ID
            string NewsLxIdWebSite = "";

            //栏目ID
            string ColumnidWebSite = "";

            //新闻生成文件名
            string NewsCrtFileName = "";

            //当前栏目级别
            int CurrColumnIDLv = 0;


            if (LX == "News")//新闻ID
            {
                NewsIDWebSite = CurrID;//传入新闻ID
                WebSiteTable = TextData.SqlataSet("select * FROM [CX_NEWS] where CX_NEWS_id=" + NewsIDWebSite).Tables[0];
                try
                {
                    string NewsName = WebSiteTable.Rows[0]["CX_NEWS_Name"].ToString();//得到新闻名

                    NewsLxIdWebSite = WebSiteTable.Rows[0]["CX_NEWS_Class_id"].ToString();//得到新闻 分类 ID
                    //新闻生成文件名
                    NewsCrtFileName = SiteGetNewsSetCrtDir(NewsIDWebSite) + SiteGetNewsFileLast(NewsIDWebSite) + NewsIDWebSite + ".html";

                    //开始得到栏目ID 
                    WebSiteTable = TextData.SqlataSet("select * FROM [CX_NEWS_Class] where [CX_NEWS_Class_id]=" + NewsLxIdWebSite).Tables[0];
                    ColumnidWebSite = WebSiteTable.Rows[0]["CX_Column_id"].ToString();//得到栏目 ID
                    //当前栏目级别
                    CurrColumnIDLv = SiteGetColumnLv(0, int.Parse(ColumnidWebSite));

                    WebSiteTable = TextData.SqlataSet("select *  FROM [CX_Column] where CX_Column_id=" + ColumnidWebSite).Tables[0];
                    //一级一级的得到栏目
                    for (int i = CurrColumnIDLv; i >= 0; i--)
                    {
                        if (i == 0)//如果是当前栏目ID的栏目
                        {
                            websitetext += "<a href=" + WebSiteTable.Rows[0]["CX_Column_Directory"].ToString() + "1.html>" + WebSiteTable.Rows[0]["CX_Column_Name"].ToString() + "</a>";

                        }
                        else
                        {
                            WEBSiteTable = GetTopCloumns(ColumnidWebSite, i);
                            websitetext += "<a href=" + WEBSiteTable.Rows[0]["CX_Column_Directory"].ToString() + "1.html>" + WEBSiteTable.Rows[0]["CX_Column_Name"].ToString() + "</a>&gt;&gt;";
                        }

                    }

                    websitetext += "&gt;&gt;<a href=\"" + NewsCrtFileName + "\">" + NewsName + "</a>";

                }
                catch (Exception ex)
                {
                    websitetext = ex.Message;
                }

            }

            if (LX == "Newslx")//新闻类型ＩＤ
            {
                NewsLxIdWebSite = CurrID;////传入新闻　类型ＩＤ

                //开始得到栏目ID 
                WebSiteTable = TextData.SqlataSet("select * FROM [CX_NEWS_Class] where [CX_NEWS_Class_id]=" + NewsLxIdWebSite).Tables[0];
                try
                {

                    ColumnidWebSite = WebSiteTable.Rows[0]["CX_Column_id"].ToString();//得到栏目 ID
                    //当前栏目级别
                    CurrColumnIDLv = SiteGetColumnLv(0, int.Parse(ColumnidWebSite));

                    WebSiteTable = TextData.SqlataSet("select *  FROM [CX_Column] where CX_Column_id=" + ColumnidWebSite).Tables[0];
                    //一级一级的得到栏目
                    for (int i = CurrColumnIDLv; i >= 0; i--)
                    {
                        if (i == 0)//如果是当前栏目ID的栏目
                        {
                            websitetext += "<a href=" + WebSiteTable.Rows[0]["CX_Column_Directory"].ToString() + "1.html>" + WebSiteTable.Rows[0]["CX_Column_Name"].ToString() + "</a>";

                        }
                        else
                        {
                            WEBSiteTable = GetTopCloumns(ColumnidWebSite, i);
                            websitetext += "<a href=" + WEBSiteTable.Rows[0]["CX_Column_Directory"].ToString() + "1.html>" + WEBSiteTable.Rows[0]["CX_Column_Name"].ToString() + "</a>&gt;&gt;";
                        }

                    }

                    websitetext += NewsCrtFileName;

                }
                catch (Exception ex)
                {
                    websitetext = ex.Message;
                }
            }

            if (LX == "Column")//直接是栏目ID
            {
                try
                {

                    ColumnidWebSite = CurrID;//得到栏目 ID
                    //当前栏目级别
                    CurrColumnIDLv = SiteGetColumnLv(0, int.Parse(ColumnidWebSite));

                    WebSiteTable = TextData.SqlataSet("select *  FROM [CX_Column] where CX_Column_id=" + ColumnidWebSite).Tables[0];
                    //一级一级的得到栏目
                    for (int i = CurrColumnIDLv; i >= 0; i--)
                    {
                        if (i == 0)//如果是当前栏目ID的栏目
                        {
                            websitetext += "<a href=" + WebSiteTable.Rows[0]["CX_Column_Directory"].ToString() + "1.html>" + WebSiteTable.Rows[0]["CX_Column_Name"].ToString() + "</a>";

                        }
                        else
                        {
                            WEBSiteTable = GetTopCloumns(ColumnidWebSite, i);
                            websitetext += "<a href=" + WEBSiteTable.Rows[0]["CX_Column_Directory"].ToString() + "1.html>" + WEBSiteTable.Rows[0]["CX_Column_Name"].ToString() + "</a>&gt;&gt;";
                        }

                    }

                    websitetext += NewsCrtFileName;

                }
                catch (Exception ex)
                {
                    websitetext = ex.Message;
                }
            }
            return "<a href=\"" + "/" + "\">首页</a>&gt;&gt;" + websitetext;
        }


        #endregion



        /// <summary>
        /// 执行方法 AddNewCX_loginState(Request.Cookies["admin"].Value,"CX_News_Edit.aspx","删除新闻，你看到了我")
        /// 添加新操作记录的东东
        /// 添加文件 Loginx.aspx 登录系统
        /// 添加文件 CX_Collert_Show_State0.aspx 操作采集信息 审核了什么新闻 
        /// 添加文件 CX_Collert_Show_State1.aspx 审核了更新新闻 
        /// 添加文件 CX_Create_HTML_Column.aspx  执行生成操作 什么栏目
        /// 添加文件 CX_News_AddNew.aspx 执行添加新闻 
        /// 添加文件 CX_News_Edit.aspx 执行编辑新闻 
        /// 添加文件 CX_News_Show.aspx 执行删除新闻
        /// </summary>
        /// <param name="usr">执行操作的用户 AddNewCX_loginState</param>
        /// <param name="PageName">执行操作的页面</param>
        /// <param name="ActionInfo">操作信息</param>
        public void AddNewCX_loginState(string usr, string PageName, string ActionInfo)
        {
            try
            {
                string UseruName = TextData.SqlataSet("select UseName from [Use] where  uid = '" + usr + "'").Tables[0].Rows[0]["UseName"].ToString();
                string loginStateSql = "insert into [CX_loginState] (";
                loginStateSql += "CX_loginState_uid,CX_loginState_Name,CX_loginState_ActionTime,CX_loginState_ActionInfo) values";
                loginStateSql += "('" + usr + "','" + UseruName + "','" + DateTime.Now.ToString() + "','" + ActionInfo + "')";
                TextData.SqlDataSave(loginStateSql);
            }
            catch
            {

            }
        }


        #region 数据表现形式代码
        ///输出HTML代码
        string selectMueuOption_outHTML = "";
        int selectMueuOptionii = 0;
        //生成栏目 下拉列表 的 select 
        //栏目 不是最下的用 <optgroup label="网站开发区"/>来让用户不能进行操作
        /// <summary>
        /// 生成栏目 下拉列表 的 select 中的 option 和组
        /// </summary>
        /// <param name="follwid">要从开始的ID 一般为 0</param>
        /// <param name="CheckID">选择的ID string 类型</param>
        /// <returns>下拉列表 的 select 中的 option 和组 HTML代码</returns>
        public String selectMueuOption(int follwid, string CheckID)
        {


            //输出SQL代码
            string selectMueuOption_sql = "";

            //DataTable 用于保存此方法里的所有数据
            DataTable selectMueuOption_DataTable = new DataTable();

            selectMueuOption_sql = "select * from [CX_Column] where CX_Column_followid=" + follwid + " order by CX_Column_Sort desc,CX_Column_id desc";//出栏目表里的所有表以 CX_Column_Sort 排序,或以 CX_Column_id 排
            try
            {

                selectMueuOption_DataTable = TextData.SqlataSet(selectMueuOption_sql).Tables[0];//创建DataTable selectMueuOption_sql
            }
            catch (Exception ex)
            {
                TextData.Err(ex.Message);

            }


            //这里开始输出option
            for (int selectMueuOptioni = 0; selectMueuOptioni < selectMueuOption_DataTable.Rows.Count; selectMueuOptioni++)//遁环记录集
            {

                //有子栏目
                if (TextData.SqlataSet("Select * From CX_Column where CX_Column_LX<>3 and CX_Column_followid =" + selectMueuOption_DataTable.Rows[selectMueuOptioni]["CX_Column_id"].ToString() + " order by CX_Column_id desc").Tables[0].Rows.Count > 0)
                {
                    selectMueuOption_outHTML += "<optgroup style=\"font-weight: normal; vertical-align: baseline; color: #000066; text-indent: 0pt; line-height: normal; font-style: normal; font-family: 'Agency FB'; letter-spacing: normal; text-align: left; font-variant: normal;\" label=\"" + TextData.EStr(selectMueuOptionii, "…") + selectMueuOption_DataTable.Rows[selectMueuOptioni]["CX_Column_Name"].ToString() + "\"></optgroup>\r\n";
                }
                else
                {
                    //这里看看新闻设定里有没有这个栏目下的分类 如果有的话将显示分类 
                    DataTable selectMenuOptionNewsTable = new DataTable();
                    selectMenuOptionNewsTable = TextData.SqlataSet("select CX_NEWS_Class_id,CX_Column_id,CX_NEWS_Class_Name  From [CX_NEWS_Class] where CX_Column_id=" + selectMueuOption_DataTable.Rows[selectMueuOptioni]["CX_Column_id"].ToString()).Tables[0];

                    //把新闻表里的分类全部读出来 如果没有将不显示 
                    //注意 下新闻 分类联在一起 如果您要将栏目显示出来一定要将新闻分类中邦定相关栏目
                    for (int selectj = 0; selectj < selectMenuOptionNewsTable.Rows.Count; selectj++)
                    {
                        if (selectMenuOptionNewsTable.Rows[selectj]["CX_NEWS_Class_id"].ToString() == CheckID)
                        {

                            selectMueuOption_outHTML += "\t<option  value=\"" + selectMenuOptionNewsTable.Rows[selectj]["CX_NEWS_Class_id"].ToString() + "\" selected=\"selected\" >" + TextData.EStr(selectMueuOptionii, "…") + selectMenuOptionNewsTable.Rows[selectj]["CX_NEWS_Class_Name"].ToString() + "</option>\r\n";
                        }
                        else
                        {
                            selectMueuOption_outHTML += "\t<option  value=\"" + selectMenuOptionNewsTable.Rows[selectj]["CX_NEWS_Class_id"].ToString() + "\">" + TextData.EStr(selectMueuOptionii, "…") + selectMenuOptionNewsTable.Rows[selectj]["CX_NEWS_Class_Name"].ToString() + "</option>\r\n";

                        }
                    }
                    selectMenuOptionNewsTable.Clear();
                    selectMenuOptionNewsTable.Dispose();
                }

                selectMueuOptionii = selectMueuOptionii + 1;
                if (selectMueuOption_DataTable.Rows.Count >= 1)//如果有子栏目
                {
                    selectMueuOption(int.Parse(selectMueuOption_DataTable.Rows[selectMueuOptioni]["CX_Column_id"].ToString()), CheckID);//调用自己显示菜单ＨＴＭＬ
                }
                selectMueuOptionii -= 1;

            }

            return selectMueuOption_outHTML;
        }


        //
        //
        /// <summary>
        /// 传入一个以 , 分开的字符串输出是不是显示的代码 返回输出JS 用于控制栏目与新闻的输入显示权限 
        /// </summary>
        /// <param name="strNums">string 数组</param>
        /// <returns></returns>
        public String IsShowElement(string serElements)
        {
            string[] strNums = serElements.Split(',');
            string scripttext = "";
            for (int i = 0; i < strNums.Length; i++)
            {
                if (strNums[i].Trim() != "")
                {
                    try
                    {
                        if (Convert.ToBoolean(TextData.Res.Request.QueryString[strNums[i]].ToString()))
                        {
                            scripttext += "document.getElementById(\"" + strNums[i] + "\").style.display='block';\r\n";
                        }
                        else
                        {
                            scripttext += "document.getElementById(\"" + strNums[i] + "\").style.display='none';\r\n";
                        }
                    }
                    catch
                    {
                        scripttext += "document.getElementById(\"" + strNums[i] + "\").style.display='none';\r\n";
                    }
                }
            }

            return scripttext;
        }
        #endregion

        /// <summary>
        /// 传入一个表名 在数据库中创建一个这样的表 返回 bool 值
        /// </summary>
        /// <param name="tab">表名</param>
        /// <returns></returns>
        public bool CreatTab(string tab)
        {
            bool sqlexestate = false;
            string sqlexe = "";





            sqlexe += "" +

       "CREATE TABLE [" + tab + "] (\r\n" +
    "[" + tab + "_id] [decimal](18, 0) IDENTITY (1, 1) NOT NULL , --创建ID\r\n" +
    "[" + tab + "_Name] [nvarchar](500) COLLATE Chinese_PRC_CI_AS NULL , -- 创建 标题名称\r\n" +
    "[" + tab + "_Contont] [text] COLLATE Chinese_PRC_CI_AS NULL ,  --  内容\r\n" +
    "[" + tab + "_PublicTime] [datetime] NULL , --  发布时间\r\n" +

    "[" + tab + "_Pic] [nvarchar](500) COLLATE Chinese_PRC_CI_AS NULL , -- 显示图片\r\n" +

    "[" + tab + "_Explier] [nvarchar] (500) COLLATE Chinese_PRC_CI_AS NULL , --  说明\r\n" +

    "[" + tab + "_Sort] [int]   NULL , --  排序\r\n" +

    "[" + tab + "_CreatefileName] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL , --  生成文件名\r\n" +
    "[" + tab + "_Link] [nvarchar] (500) COLLATE Chinese_PRC_CI_AS NULL , --  链接地址\r\n" +

    "[" + tab + "_LX] [int]   NULL , --  显示方式\r\n" +
")\r\n" +

        "-- 开始给表创建 主键  " + tab + " 为表名 " + tab + "id 为主键ID\r\n" +
       "ALTER TABLE [" + tab + "] WITH NOCHECK ADD \r\n" +
    "CONSTRAINT [PK_" + tab + "] PRIMARY KEY  CLUSTERED \r\n" +
    "(\r\n" +
        "[" + tab + "_id]\r\n" +
    ") \r\n" +
     "  \r\n" +

      "-- select * from [CX_Column]\r\n" +
      " --开始设定自动创建表的数据\r\n";
            TextData.SqlDataSave(sqlexe);
            TextData.SqlDataSave("insert into [" + tab + "] ([" + tab + "_Name]) values('system') ");//添加一条空记录用于生成
            sqlexestate = true;

            return sqlexestate;

        }




    }

    /// <summary>
    /// 复选框操作
    /// </summary>
    public class CheckBox
    {


        /// <summary>
        /// 传入 以选的ID
        /// 创建 text box;
        /// </summary>
        /// <![CDATA[ {1,2,547,8,79,79,98,4 }    CreateCheckBox("5");
        /// ]]>
        internal string CreateCheckBox(string key_id, DataTable CheckBoxClassTable)
        {
            string[] Cx_id;
            string str = "";
            Cx_id = key_id.Split(',');//以 ' 分开 得到数组

            DataTable KeyClass = CheckBoxClassTable;
            for (int i = 0; i < KeyClass.Rows.Count; i++)
            {



                if (ISCheckBoxCreate(Cx_id, KeyClass.Rows[i]["CX_keyWord_Class_id"].ToString().Trim()))//如果选定
                {
                    str += "<input id=\"keyWord_Name\" name=\"keyWord_Name\" type=\"checkbox\" value=\"" + KeyClass.Rows[i]["CX_keyWord_Class_id"].ToString().Trim() + "\" checked=\"checked\" /> " + KeyClass.Rows[i]["CX_keyWord_Class_Name"].ToString().Trim() + "   ";

                }
                else
                {
                    str += "<input id=\"keyWord_Name\" name=\"keyWord_Name\" type=\"checkbox\" value=\"" + KeyClass.Rows[i]["CX_keyWord_Class_id"].ToString().Trim() + "\"  /> " + KeyClass.Rows[i]["CX_keyWord_Class_Name"].ToString().Trim() + "   ";
                }

            }
            return str;

        }

        /// <summary>
        ///  看看数组里是不是存在 这个ID
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        protected bool ISCheckBoxCreate(string[] shuZhu, string id)
        {
            for (int i = 0; i < shuZhu.Length; i++)
            {
                if (id == shuZhu[i])
                {
                    return true;
                }
            }
            return false;
        }
    }


    /// <summary>
    /// 生成页面操作类 可按栏目生成相对应的新闻 2007-10-11
    /// </summary>
    public class CreateSiteHTMlFile
    {

        #region 变量设定
        /// <summary>
        /// 数据操作方法
        /// </summary>
        TongUse TextData = new TongUse();

        DataTable Create_MyDt = new DataTable();

        /// <summary>
        /// 用于保存数据的DAtaTable
        /// </summary>
        DataTable Create_NewDt = new DataTable();

        /// <summary>
        /// 得到栏目的模板
        /// </summary>
        string getItempatate = "";

        /// <summary>
        /// 得到模板地址参数 
        /// </summary>
        string getItempateParam = "";

        /// <summary>
        /// 生成文件名前 面 的东东
        /// </summary>
        string getitempateFrontFilename = "";

        /// <summary>
        /// 得到栏目要写入的url
        /// </summary>
        string getWriteUrl = "";

        /// <summary>
        /// 要生成的新闻id 
        /// </summary>
        string getNewsId = "";

        /// <summary>
        /// 得到栏目ID 
        /// </summary>
        string getItempid = "";

        /// <summary>
        /// 得到新闻设定栏目
        /// </summary>
        string getNews_Column = "";

        /// <summary>
        /// 得到新闻类型的ID
        /// </summary>
        string getNewsLxid = "";

        /// <summary>
        /// 得到数据的URL
        /// </summary>
        string GetUrl = "";

        /// <summary>
        /// 栏目类型 0为 一般栏目，1 为新闻栏目
        /// </summary>
        string CX_Column_LX = "";
        #endregion
        /// <summary>
        /// 创建最新新闻
        /// </summary>
        /// <param name="CreateNewssum"> 要生成最新多少条 </param>
        /// <returns></returns>
        public string Creat_New_News(int CreateNewssum)
        {
            int crtshu = 0;

            if (CreateNewssum > 0)
            {


                try
                {
                    //得到新闻 id 与新闻 类型
                    Create_NewDt = TextData.SqlataSet("select  top  " + CreateNewssum + " *  FROM [CX_NEWS] order by CX_NEWS_id desc").Tables[0];
                    for (int i = 0; i < Create_NewDt.Rows.Count; i++)
                    {
                        getNewsId = Create_NewDt.Rows[i]["CX_NEWS_id"].ToString();
                        getNews_Column = Create_NewDt.Rows[i]["CX_NEWS_Class_id"].ToString().Trim();
                        //对应新闻类型的


                        Create_MyDt = TextData.SqlataSet("select top 1 * FROM [CX_NEWS_Class] where CX_NEWS_Class_id  = " + getNews_Column).Tables[0];

                        getItempatate = Create_MyDt.Rows[0]["CX_NEWS_Class_Itemplitate_Address"].ToString(); //模板地址
                        getItempateParam = Create_MyDt.Rows[0]["CX_NEWS_Class_Itemplitate_Parame"].ToString(); //模板参数 
                        getitempateFrontFilename = Create_MyDt.Rows[0]["CX_NEWS_Class_CreateFielfront"].ToString(); //模板参数 生成文件名前缀 :
                        getItempid = Create_MyDt.Rows[0]["CX_Column_id"].ToString(); //新闻的栏目ID 
                        getNewsLxid = Create_MyDt.Rows[0]["CX_NEWS_Class_id"].ToString();
                        //Create_MyDt.Clear();


                        //生成新闻栏目 用于 生成目录 与 栏目
                        //Create_MyDt = TextData.SqlataSet("select top 1 * FROM [CX_Column] where CX_Column_id  = " + getItempid).Tables[0];

                        TextData.DirCreate(TextData.Res.Server.MapPath(Create_MyDt.Rows[0]["CX_NEWS_Class_Directory"].ToString().Trim()));//创建栏目目录

                        /////静态页面 ////////////////////////////////////////////////////////////////////////////
                        getWriteUrl = TextData.Res.Server.MapPath(Create_MyDt.Rows[0]["CX_NEWS_Class_Directory"].ToString() + getitempateFrontFilename + getNewsId + ".html");
                        GetUrl = getItempatate + getItempateParam.Replace("$", getNewsId) + "&Class=" + getNewsLxid;

                        Create_MyDt.Dispose();//清空变量

                        // TextData.Res.Response.Write(getWriteUrl + "<br>" + GetUrl + "<br>页面");////测试
                        ///生成显示内容静态页面
                        TextData.GetWebDataWrite(GetUrl, getWriteUrl);

                        //每 秒生成10条 每100毫秒生成一条
                        System.Threading.Thread.Sleep(100);
                        crtshu++;


                    }
                }
                catch (Exception ex)
                {
                    System.GC.Collect();
                    return "生成失败 已生成" + crtshu + "个文件 出错新闻 ID :" + getNewsId + " <br/>";

                }

            }
            //Create_NewDt.Clear();
            Create_NewDt.Dispose();


            //生成新闻栏目
            DataTable cctableucc = new DataTable();
            cctableucc = TextData.SqlataSet("select * FROM [CX_NEWS_Class]").Tables[0];
            for (int j = 0; j < cctableucc.Rows.Count; j++)
            {
                // Creat_Column("5");//这里表示新闻



            }

            //Create_NewDt.Clear();
            //Create_NewDt.Dispose();

            return "";
        }



        /// <summary>
        /// 按栏目生成操作 
        /// </summary>
        /// <param name="ColumnID">栏目 ID 及生成栏目的文件名</param>
        /// <returns></returns>
        public string Creat_Column(string ColumnID)
        {
            //这里的栏目生成 目前还不能生成 id=$后页面的页面 请指定

            string TableX = "";//要读取的数据库表
            int crtshu = 0;
            //Create_MyDt.Clear();
            //Create_MyDt.Dispose();

            try
            {
                Create_MyDt = TextData.SqlataSet("select top 1 * FROM [CX_Column] where CX_Column_id  = " + ColumnID).Tables[0];
                TextData.DirCreate(TextData.Res.Server.MapPath(Create_MyDt.Rows[0]["CX_Column_Directory"].ToString().Trim()));//创建栏目目录
                CX_Column_LX = Create_MyDt.Rows[0]["CX_Column_LX"].ToString();//得到栏目类型




                //如果是新闻 显示页面
                if (CX_Column_LX == "1")
                {
                    //用栏目ID 得到所有新闻分类ID
                    TableX = "CX_News";//是新闻就设定新闻表

                    //新闻分类的表
                    DataTable CX_News_ClassTable = new DataTable();//新闻TAB

                    CX_News_ClassTable = TextData.SqlataSet("select * from [CX_NEWS_Class] where CX_Column_id =" + ColumnID).Tables[0];//得到此栏目下所有的新闻设定


                    //循环 这个栏目下的 新闻分类
                    for (int j = 0; j < CX_News_ClassTable.Rows.Count; j++)
                    {
                        getitempateFrontFilename = CX_News_ClassTable.Rows[j]["CX_NEWS_Class_CreateFielfront"].ToString().Trim(); //模板参数 生成文件名前缀 :
                        TextData.DirCreate(TextData.Res.Server.MapPath(CX_News_ClassTable.Rows[j]["CX_NEWS_Class_Directory"].ToString().Trim()));//创建 新闻 栏目 目录 如果存在不创建
                        getNewsLxid = CX_News_ClassTable.Rows[j]["CX_NEWS_Class_id"].ToString().Trim();

                        //按条件得到些新闻设定下的所有新闻
                        Create_NewDt = TextData.SqlataSet("select * FROM [" + TableX + "]  where CX_NEWS_Class_id=" + getNewsLxid).Tables[0];
                        for (int i = 0; i < Create_NewDt.Rows.Count; i++)
                        {
                            getWriteUrl = TextData.Res.Server.MapPath(CX_News_ClassTable.Rows[j]["CX_NEWS_Class_Directory"].ToString().Trim() + getitempateFrontFilename + Create_NewDt.Rows[i][TableX + "_id"].ToString() + ".html");
                            GetUrl = CX_News_ClassTable.Rows[j]["CX_NEWS_Class_Itemplitate_Address"].ToString().Trim() + CX_News_ClassTable.Rows[j]["CX_NEWS_Class_Itemplitate_Parame"].ToString().Trim().Replace("$", Create_NewDt.Rows[i][TableX + "_id"].ToString() + "&Class=" + getNewsLxid);
                            //写入数据 List 页面
                            TextData.GetWebDataWrite(GetUrl, getWriteUrl);
                            crtshu++;//新加一个文件生成数
                            System.Threading.Thread.Sleep(100);//指定30 毫秒生成一次 
                            //System.Web.HttpContext.Current.Response.Write("<br>" + GetUrl);
                        }
                        Create_NewDt.Clear();
                        Create_NewDt.Dispose();
                    }

                    //新闻生成完成  要生成列表页面 执行 
                    TableX = Create_MyDt.Rows[0]["CX_CX_Column_Tab_Name"].ToString().Trim();
                    Create_NewDt = TextData.SqlataSet("select * FROM [" + TableX + "] ").Tables[0];
                    for (int i = 0; i < Create_NewDt.Rows.Count; i++)
                    {

                        getWriteUrl = TextData.Res.Server.MapPath(Create_MyDt.Rows[0]["CX_Column_Directory"].ToString().Trim() + Create_NewDt.Rows[i][TableX + "_id"].ToString() + ".html");
                        GetUrl = Create_MyDt.Rows[0]["CX_Column_ItemTemplate_Url"].ToString().Trim() + Create_MyDt.Rows[0]["CX_Column_ItemTeplate_Parame"].ToString().Trim().Replace("$", Create_NewDt.Rows[i][TableX + "_id"].ToString());
                        //写入数据 List 页面

                        TextData.GetWebDataWrite(GetUrl, getWriteUrl);
                        crtshu++;//新加一个文件生成数
                        System.Threading.Thread.Sleep(100);//指定30 毫秒生成一次 
                    }
                    //生成栏目列表页面结束


                    GC.Collect();//清空LJ
                    CX_News_ClassTable.Dispose();//清空变量

                }
                else
                {
                    //得到栏目表
                    TableX = Create_MyDt.Rows[0]["CX_CX_Column_Tab_Name"].ToString().Trim();
                    Create_NewDt = TextData.SqlataSet("select * FROM [" + TableX + "] ").Tables[0];


                    for (int i = 0; i < Create_NewDt.Rows.Count; i++)
                    {

                        getWriteUrl = TextData.Res.Server.MapPath(Create_MyDt.Rows[0]["CX_Column_Directory"].ToString().Trim() + Create_NewDt.Rows[i][TableX + "_id"].ToString() + ".html");
                        GetUrl = Create_MyDt.Rows[0]["CX_Column_ItemTemplate_Url"].ToString().Trim() + Create_MyDt.Rows[0]["CX_Column_ItemTeplate_Parame"].ToString().Trim().Replace("$", Create_NewDt.Rows[i][TableX + "_id"].ToString());
                        //写入数据 List 页面

                        TextData.GetWebDataWrite(GetUrl, getWriteUrl);
                        crtshu++;//新加一个文件生成数
                        System.Threading.Thread.Sleep(100);//指定30 毫秒生成一次 
                        // System.Web.HttpContext.Current.Response.Write("<br>" + getWriteUrl);

                    }

                }



                //Create_MyDt.Clear();
                Create_MyDt.Dispose();
                //Create_NewDt.Clear();
                Create_NewDt.Dispose();
            }
            catch (Exception ex)
            {
                System.GC.Collect();
                return "生成失败 已生成" + crtshu + "个文件 出错栏目 ID :" + ColumnID + "";
                //结束进程
                //System.Diagnostics.Process[] ps = System.Diagnostics.Process.GetProcesses();
                //for (int i = 0; i < ps.Length; i++)
                //{

                //    if (ps[i].ProcessName.ToLower() == "aspnet_wp")
                //    {
                //        ps[i].Kill();
                //    }
                //}
            }
            return "";
        }




        /// <summary>
        /// 指定新闻ID 生成一打新闻
        /// </summary>
        /// <param name="NewsID">指定新闻ID</param>
        /// <returns></returns>
        public String Create_News_POintNewsID(string NewsID)
        {
            int crtshu = 0;

            try
            {
                //得到新闻 id 与新闻 类型
                Create_NewDt = TextData.SqlataSet("select  top 1   *  FROM [CX_NEWS] where CX_NEWS_id=" + NewsID + "  order by CX_NEWS_id desc").Tables[0];
                for (int i = 0; i < Create_NewDt.Rows.Count; i++)
                {
                    getNewsId = Create_NewDt.Rows[i]["CX_NEWS_id"].ToString();
                    getNews_Column = Create_NewDt.Rows[i]["CX_NEWS_Class_id"].ToString().Trim();
                    //对应新闻类型的


                    Create_MyDt = TextData.SqlataSet("select top 1 * FROM [CX_NEWS_Class] where CX_NEWS_Class_id  = " + getNews_Column).Tables[0];

                    getItempatate = Create_MyDt.Rows[0]["CX_NEWS_Class_Itemplitate_Address"].ToString(); //模板地址
                    getItempateParam = Create_MyDt.Rows[0]["CX_NEWS_Class_Itemplitate_Parame"].ToString(); //模板参数 
                    getitempateFrontFilename = Create_MyDt.Rows[0]["CX_NEWS_Class_CreateFielfront"].ToString(); //模板参数 生成文件名前缀 :
                    getItempid = Create_MyDt.Rows[0]["CX_Column_id"].ToString(); //新闻的栏目ID 
                    getNewsLxid = Create_MyDt.Rows[0]["CX_NEWS_Class_id"].ToString();
                    //Create_MyDt.Clear();


                    //生成新闻栏目 用于 生成目录 与 栏目
                    //Create_MyDt = TextData.SqlataSet("select top 1 * FROM [CX_Column] where CX_Column_id  = " + getItempid).Tables[0];

                    TextData.DirCreate(TextData.Res.Server.MapPath(Create_MyDt.Rows[0]["CX_NEWS_Class_Directory"].ToString().Trim()));//创建栏目目录

                    /////静态页面 ////////////////////////////////////////////////////////////////////////////
                    getWriteUrl = TextData.Res.Server.MapPath(Create_MyDt.Rows[0]["CX_NEWS_Class_Directory"].ToString() + getitempateFrontFilename + getNewsId + ".html");
                    GetUrl = getItempatate + getItempateParam.Replace("$", getNewsId) + "&Class=" + getNewsLxid;

                    Create_MyDt.Dispose();//清空变量

                    // TextData.Res.Response.Write(getWriteUrl + "<br>" + GetUrl + "<br>页面");////测试
                    ///生成显示内容静态页面
                    string Crtcheng = TextData.GetWebDataWrite(GetUrl, getWriteUrl);

                    //每 秒生成10条 每100毫秒生成一条
                    System.Threading.Thread.Sleep(100);
                    crtshu++;

                    return Crtcheng;
                }
            }
            catch (Exception ex)
            {
                System.GC.Collect();
                return "生成失败 已生成" + crtshu + "个文件 出错新闻 ID :" + getNewsId + " <br/>";

            }
            return "";
        }

    }

    #region 文件生成操作类 此操作类没能 把新闻按栏目生成  2007-10-11
    /*
/// <summary>
/// 生成页面操作类
/// </summary>
/// 
public class CreateSiteHTMlFile
{
    /// <summary>
    /// 数据操作方法
    /// </summary>
    TongUse TextData = new TongUse();

    DataTable Create_MyDt = new DataTable();

    DataTable Create_NewDt = new DataTable();
    /// <summary>
    /// 得到栏目的模板
    /// </summary>
    string getItempatate = "";

    /// <summary>
    /// 得到模板地址参数 
    /// </summary>
    string getItempateParam = "";

    /// <summary>
    /// 生成文件名前 面 的东东
    /// </summary>
    string getitempateFrontFilename = "";

    /// <summary>
    /// 得到栏目要写入的url
    /// </summary>
    string getWriteUrl = "";

    /// <summary>
    /// 要生成的新闻id 
    /// </summary>
    string getNewsId = "";

    /// <summary>
    /// 得到栏目ID 
    /// </summary>
    string getItempid = "";

    /// <summary>
    /// 得到新闻设定栏目
    /// </summary>
    string getNews_Column = "";

    /// <summary>
    /// 得到新闻类型的ID
    /// </summary>
    string getNewsLxid = "";

    /// <summary>
    /// 得到数据的URL
    /// </summary>
    string GetUrl = "";

    /// <summary>
    /// 创建最新新闻
    /// </summary>
    /// <param name="CreateNewssum"> 要生成最新多少条 </param>
    /// <returns></returns>
    public string Creat_New_News(int CreateNewssum)
    {
        int crtshu = 0;

        if (CreateNewssum > 0)
        {


            try
            {
                //得到新闻 id 与新闻 类型
                Create_NewDt = TextData.SqlataSet("select  top  " + CreateNewssum + " *  FROM [CX_NEWS] order by CX_NEWS_id desc").Tables[0];
                for (int i = 0; i < Create_NewDt.Rows.Count; i++)
                {
                    getNewsId = Create_NewDt.Rows[i]["CX_NEWS_id"].ToString();
                    getNews_Column = Create_NewDt.Rows[i]["CX_NEWS_Class_id"].ToString().Trim();
                    //对应新闻类型的


                    Create_MyDt = TextData.SqlataSet("select top 1 * FROM [CX_NEWS_Class] where CX_NEWS_Class_id  = " + getNews_Column).Tables[0];

                    getItempatate = Create_MyDt.Rows[0]["CX_NEWS_Class_Itemplitate_Address"].ToString(); //模板地址
                    getItempateParam = Create_MyDt.Rows[0]["CX_NEWS_Class_Itemplitate_Parame"].ToString(); //模板参数 
                    getitempateFrontFilename = Create_MyDt.Rows[0]["CX_NEWS_Class_CreateFielfront"].ToString(); //模板参数 生成文件名前缀 :
                    getItempid = Create_MyDt.Rows[0]["CX_Column_id"].ToString(); //新闻的栏目ID 
                    getNewsLxid = Create_MyDt.Rows[0]["CX_NEWS_Class_id"].ToString();
                    //Create_MyDt.Clear();


                    //生成新闻栏目 用于 生成目录 与 栏目
                    //Create_MyDt = TextData.SqlataSet("select top 1 * FROM [CX_Column] where CX_Column_id  = " + getItempid).Tables[0];

                    TextData.DirCreate(TextData.Res.Server.MapPath(Create_MyDt.Rows[0]["CX_NEWS_Class_Directory"].ToString().Trim()));//创建栏目目录

                    /////静态页面 ////////////////////////////////////////////////////////////////////////////
                    getWriteUrl = TextData.Res.Server.MapPath(Create_MyDt.Rows[0]["CX_NEWS_Class_Directory"].ToString() + getitempateFrontFilename + getNewsId + ".html");
                    GetUrl = getItempatate + getItempateParam.Replace("$", getNewsId);

                    Create_MyDt.Dispose();//清空变量

                    // TextData.Res.Response.Write(getWriteUrl + "<br>" + GetUrl + "<br>页面");////测试
                    ///生成显示内容静态页面
                    TextData.GetWebDataWrite(GetUrl, getWriteUrl);

                    //每 秒生成10条 每100毫秒生成一条
                    System.Threading.Thread.Sleep(100);
                    crtshu++;


                }
            }
            catch (Exception ex)
            {
                System.GC.Collect();
                return "生成失败 已生成" + crtshu + "个文件 出错新闻 ID :" + getNewsId + " <br/>";

            }

        }
        //Create_NewDt.Clear();
        Create_NewDt.Dispose();


        //生成新闻栏目
        DataTable cctableucc = new DataTable();
        cctableucc = TextData.SqlataSet("select * FROM [CX_NEWS_Class]").Tables[0];
        for (int j = 0; j < cctableucc.Rows.Count; j++)
        {
            // Creat_Column("5");//这里表示新闻



        }

        //Create_NewDt.Clear();
        //Create_NewDt.Dispose();

        return "";
    }



    /// <summary>
    /// 按栏目生成操作 
    /// </summary>
    /// <param name="ColumnID">栏目 ID 及生成栏目的文件名</param>
    /// <returns></returns>
    public string Creat_Column(string ColumnID)
    {
        //这里的栏目生成 目前还不能生成 id=$后页面的页面 请指定

        string TableX = "";//要读取的数据库表
        int crtshu = 0;
        //Create_MyDt.Clear();
        //Create_MyDt.Dispose();

        try
        {
            Create_MyDt = TextData.SqlataSet("select top 1 * FROM [CX_Column] where CX_Column_id  = " + ColumnID).Tables[0];
            TextData.DirCreate(TextData.Res.Server.MapPath(Create_MyDt.Rows[0]["CX_Column_Directory"].ToString().Trim()));//创建栏目目录

            TableX = Create_MyDt.Rows[0]["CX_CX_Column_Tab_Name"].ToString().Trim();

            Create_NewDt = TextData.SqlataSet("select * FROM [" + TableX + "] ").Tables[0];

            //如果是新闻 显示页面
            if (TableX == "CX_News")
            {
                DataTable CX_News_ClassTable = new DataTable();//新闻TAB

                for (int i = 0; i < Create_NewDt.Rows.Count; i++)
                {
                    getNews_Column = Create_NewDt.Rows[i]["CX_NEWS_Class_id"].ToString().Trim();
                    CX_News_ClassTable = TextData.SqlataSet("select * from [CX_NEWS_Class] where CX_NEWS_Class_id =" + getNews_Column).Tables[0];
                    getitempateFrontFilename = CX_News_ClassTable.Rows[0]["CX_NEWS_Class_CreateFielfront"].ToString().Trim(); //模板参数 生成文件名前缀 :

                    TextData.DirCreate(TextData.Res.Server.MapPath(CX_News_ClassTable.Rows[0]["CX_NEWS_Class_Directory"].ToString().Trim()));//创建 新闻 栏目 目录 如果存在不创建

                    getWriteUrl = TextData.Res.Server.MapPath(CX_News_ClassTable.Rows[0]["CX_NEWS_Class_Directory"].ToString().Trim() + getitempateFrontFilename + Create_NewDt.Rows[i][TableX + "_id"].ToString() + ".html");
                    GetUrl = CX_News_ClassTable.Rows[0]["CX_NEWS_Class_Itemplitate_Address"].ToString().Trim() + CX_News_ClassTable.Rows[0]["CX_NEWS_Class_Itemplitate_Parame"].ToString().Trim().Replace("$", Create_NewDt.Rows[i][TableX + "_id"].ToString());

                    //写入数据 List 页面
                    TextData.GetWebDataWrite(GetUrl, getWriteUrl);
                    crtshu++;//新加一个文件生成数
                    System.Threading.Thread.Sleep(100);//指定30 毫秒生成一次 
                    //System.Web.HttpContext.Current.Response.Write("<br>" + GetUrl);
                }

                CX_News_ClassTable.Dispose();//清空变量

            }
            else
            {
                for (int i = 0; i < Create_NewDt.Rows.Count; i++)
                {

                    getWriteUrl = TextData.Res.Server.MapPath(Create_MyDt.Rows[0]["CX_Column_Directory"].ToString().Trim() + Create_NewDt.Rows[i][TableX + "_id"].ToString() + ".html");
                    GetUrl = Create_MyDt.Rows[0]["CX_Column_ItemTemplate_Url"].ToString().Trim() + Create_MyDt.Rows[0]["CX_Column_ItemTeplate_Parame"].ToString().Trim().Replace("$", Create_NewDt.Rows[i][TableX + "_id"].ToString());
                    //写入数据 List 页面

                    TextData.GetWebDataWrite(GetUrl, getWriteUrl);
                    crtshu++;//新加一个文件生成数
                    System.Threading.Thread.Sleep(100);//指定30 毫秒生成一次 
                    // System.Web.HttpContext.Current.Response.Write("<br>" + getWriteUrl);

                }

            }



            //Create_MyDt.Clear();
            Create_MyDt.Dispose();
            //Create_NewDt.Clear();
            Create_NewDt.Dispose();
        }
        catch (Exception ex)
        {
            System.GC.Collect();
            return "生成失败 已生成" + crtshu + "个文件 出错栏目 ID :" + ColumnID + "";
            //结束进程
            //System.Diagnostics.Process[] ps = System.Diagnostics.Process.GetProcesses();
            //for (int i = 0; i < ps.Length; i++)
            //{

            //    if (ps[i].ProcessName.ToLower() == "aspnet_wp")
            //    {
            //        ps[i].Kill();
            //    }
            //}
        }
        return "";
    }

}*/
    #endregion

    /// <summary>
    /// 静态分页操作类
    /// 使用方法 
    /// 
    /// </summary>
    public class CreateSitePageList
    {
        int coulmnID = 0;
        int pageCount = 0;
        /// <summary>
        /// 程序输出信息
        /// </summary>
        private string info = "";


        /// <summary>
        /// 数据操作通用方法
        /// </summary>
        private Tong.TongUse TextData = new TongUse();

        /// <summary>
        /// 站点操作常用方法
        /// </summary>
        private SiteTong TextThisSite = new SiteTong();
        /// <summary>
        /// 当前栏目ID
        /// </summary>
        public int CoulmnID
        {
            get { return coulmnID; }
            set { coulmnID = value; }
        }

        /// <summary>
        /// 当前的分页总数
        /// </summary>
        public int PageCount
        {
            get { return pageCount; }
            set { pageCount = value; }
        }
        /// <summary>
        /// 程序完成的信息
        /// </summary>
        public string Info
        {
            get { return info; }
            set { info = value; }
        }
        /// <summary>
        /// 不初始化
        /// </summary>
        public CreateSitePageList()
        {
            Info = "请在实例化实体中设定PageCount和CoulmnID";
        }

        /// <summary>
        /// 传入 栏目ID 
        /// </summary>
        /// <param name="CoulmnID">栏目ID</param>
        /// <param name="pageCount">共多少页</param>
        public CreateSitePageList(string CoulmnID, int pageCount)
        {
            //栏目ID
            this.CoulmnID = int.Parse(CoulmnID);
            PageCount = pageCount;
        }

        /// <summary>
        /// 开始执行操作数据库
        /// </summary>
        public void Start()
        {

            //当数据大于0
            if (CoulmnID > 0 && PageCount > 0)
            {
                //当前的栏目表
                string CoulmnTab = TextThisSite.SigeGetColumnTable(coulmnID.ToString());

                int countTiaoShu = int.Parse(TextData.SqlataSet("SELECT count(*)  FROM [" + CoulmnTab + "] ").Tables[0].Rows[0][0].ToString());//得到总记录条数
                int cycelCount = pageCount - countTiaoShu;//得到要循环的条数

                for (int i = 0; i < cycelCount; i++)
                {
                    TextData.SqlDataSave("INSERT INTO [" + CoulmnTab + "] ([" + CoulmnTab + "_Name]) values('Page')");//添加记录条数
                }

                info = "执行操作成功";
            }
        }



    }

}